﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_UploadFile_MySelfMT : DLL.ShowLayer.BaseView
{
	private DLL.UploadFile.View clsUploadFileView;
	private DLL.UploadFile.Component clsUploadFileComp;

	public Admin_UploadFile_MySelfMT()
		: base("idTotal")
	{
		clsUploadFileView = new DLL.UploadFile.View(Page);
		clsUploadFileComp = new DLL.UploadFile.Component(Page);

		clsView = clsUploadFileView;

		AddTableColumn(new TonyNet4V1.Structs.TableShowColumn("文件名", "FileName"));
		AddTableColumn(new TonyNet4V1.Structs.TableShowColumn("栏目", "WebColumn"));
	}

	protected override void OnInit(EventArgs e)
	{
		clsUploadFileView.WebColumnIDs = Session["WebColumnIDs"].ToString();
		clsUploadFileView.nUserID = Convert.ToInt32(Session["UserID"]);
		clsUploadFileView.nDepartmentID = Convert.ToInt32(Session["DepartmentID"]);

		base.OnInit(e);

		gvTable.RowDataBound += new GridViewRowEventHandler(gvTable_RowDataBound);
	}

	void gvTable_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		int nUploadFileID;

		if (e.Row.RowIndex >= 0)
		{
			for (int i = 0; i < e.Row.Cells.Count; i++)
			{
				//if ((i != 0)  (i != (e.Row.Cells.Count - 1)))
				if ((i != 0) && (i != (e.Row.Cells.Count - 1)))
				{
					//LinkButton lBtnRead2 = new LinkButton();

					//lBtnRead2.Text = e.Row.Cells[i].Text;
					//lBtnRead2.CommandArgument = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
					//lBtnRead2.CommandName = lBtnRead.CommandName;
					//lBtnRead2.CssClass = lBtnRead.CssClass;
					e.Row.Cells[i].Controls.Clear();
					HyperLink aLink = new HyperLink();

					nUploadFileID = Convert.ToInt32(((GridView)sender).DataKeys[e.Row.RowIndex].Value);


					aLink.CssClass = "Read";
					aLink.Text = e.Row.Cells[i].Text;
					//aLink.NavigateUrl = "../ShowImageContent.aspx?FileID=" + ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
					aLink.NavigateUrl = "~/ShowFileContent.aspx?FileContentID=" + clsUploadFileComp.GetOne(nUploadFileID).FileContentID.ToString();
					aLink.Target = "_blank";

					e.Row.Cells[i].Controls.Add(aLink);
				}
			}
		}
	}

	protected void Page_Load(object sender, EventArgs e)
	{

	}

	protected override void BindGridViewNoQuery(GridView gv)
	{
		//base.BindGridViewNoQuery(gv);
		clsUploadFileView.ShowMySeflDepartmentFile(gv);
	}
}